﻿using UnityEngine;
using System.Collections;

public class ParallaxGameObject : MonoBehaviour {
	
	public int backgroundLayer = 1; //must be a value from 0 to 5
	public float myStartX = 0f;
	// Use this for initialization
	void Start () {
		
		this.transform.localPosition = new Vector3(myStartX,this.transform.localPosition.y,this.transform.localPosition.z); 
		
	}
	
	// Update is called once per frame
	void Update () {
		if((this.transform.root.position.x - Camera.main.transform.position.x) < 16){
			//Debug.Log("oia eu ai rapa");
			this.transform.position = new Vector3(this.transform.position.x + 0.3f * backgroundLayer * Time.deltaTime, this.transform.position.y, this.transform.position.z);
		
		}
	}
}
